package thread;

public class parctice5 {
    public static void main(String[] args) throws InterruptedException {
        Object locker1 = new Object();
        Object locker2 = new Object();
        Object locker3 = new Object();


        Thread t1 = new Thread(()->{
            try {
                    synchronized (locker1){
                        locker1.wait();
                    }
                    System.out.print("a");
            }catch(InterruptedException e){
                throw new RuntimeException();
            }
        });

        Thread t2 = new Thread(()->{
            try {
                synchronized (locker2){
                    locker2.wait();
                }
                System.out.print("b");
                synchronized (locker1){
                    locker1.notify();
                }
            }catch(InterruptedException e){
                throw new RuntimeException();
            }
        });

        Thread t3 = new Thread(()->{
            try {
                synchronized (locker3){
                    locker3.wait();
                }
                System.out.print("c");
                synchronized (locker2){
                    locker2.notify();
                }
            }catch(InterruptedException e){
                throw new RuntimeException();
            }
        });


        t1.start();
        t2.start();
        t3.start();

        Thread.sleep(1000);
        synchronized (locker3){
            locker3.notify();
        }
    }


}
